package com.github.sbb.sherry.console.interceptor;

import java.util.UUID;

/**
 * The type App log holder.
 */
public class AppLogHolder {

  private static final ThreadLocal<LogInfo> LOG_INFO_HOLDER = ThreadLocal.withInitial(() -> new LogInfo(UUID.randomUUID().toString()));

  // private static final ThreadLocal<LogInfo> LOG_INFO_HOLDER = new ThreadLocal<>();

  /**
   * Set.
   *
   * @param logInfo the log info
   */
  public static void set(LogInfo logInfo) {
    LOG_INFO_HOLDER.set(logInfo);
  }

  /**
   * Remove.
   */
  public static void remove() {
    LOG_INFO_HOLDER.remove();
  }

  /**
   * Get log info.
   *
   * @return the log info
   */
  public static LogInfo get() {
    return LOG_INFO_HOLDER.get();
  }

}
